<template>
  <div>
    <el-dialog
      title="图片二维码"
      width="500px"
      :visible="isShow"
      @close="$emit('update:isShow', false)"
    >
      <canvas ref="qrcodeRef" class="canvas" />
    </el-dialog>
  </div>
</template>

<script>
import Qrcode from 'qrcode'
export default {
  props: {
    isShow: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    createCode(url) {
      if (!url) {
        url =
          'http://cw2022-11-29-1312511968.cos.ap-guangzhou.myqcloud.com/Happy%20birthday%20to%20Zeng%20Tingfeng.png'
      }
      this.$nextTick(() => {
        Qrcode.toCanvas(this.$refs.qrcodeRef, url, { width: 300 })
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.canvas {
  margin-left: 50%;
  transform: translateX(-50%);
}
</style>
